home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Offscreen.c
-
- Copyright: © 1997 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #pragma segment AppSeg
-
- #ifndef Common_Defs
- #include "Common.h"
- #endif
-
-
- // *****************************************************************************
- // *
- // * DrawOffscreen()
- // *
- // *****************************************************************************
- WindowOffscreen* DrawOffscreen(WindowPtr theWindow)
- {
- WindowOffscreen* theOffscreen;
- GWorldPtr theWorld;
- Rect globalRect;
- Rect bounds = theWindow->portRect;
-
- if ((theOffscreen = (WindowOffscreen*)NewPtr(sizeof(WindowOffscreen))) == 0L)
- return(0L);
-
- SetPort(theWindow);
-
- GetGWorld(&theOffscreen->windowPort,&theOffscreen->windowDevice);
-
- globalRect = bounds;
- LocalToGlobal((Point*)&globalRect.top);
- LocalToGlobal((Point*)&globalRect.bottom);
-
- if (NewGWorld(&theWorld,0,&globalRect,0L,0L,0) == noErr)
- {
- Rect bounds = theWindow->portRect;
-
- SetGWorld(theWorld, 0L);
- if (!LockPixels(theWorld->portPixMap))
- {
- DisposeGWorld(theWorld);
- DisposePtr((Ptr)theOffscreen);
- return(0L);
- }
-
- //••!! CopyBits((BitMap*)&((theWindow->port)->portPixMap),&((GrafPtr)theWorld)->portBits,&bounds,&theWorld->portRect,srcCopy,0L);
-
- theOffscreen->offscreenWorld = theWorld;
- return theOffscreen;
- }
- else
- {
- DisposePtr((Ptr)theOffscreen);
- return 0L;
- }
- }
-
-
- // *****************************************************************************
- // *
- // * DrawOnscreen()
- // *
- // *****************************************************************************
- void DrawOnscreen(WindowOffscreen* theOffscreen)
- {
- if (theOffscreen)
- {
- SetGWorld(theOffscreen->windowPort,theOffscreen->windowDevice);
-
- CopyBits(&((GrafPtr)theOffscreen->offscreenWorld)->portBits,
- (const BitMap*) &(theOffscreen->windowPort)->portPixMap,
- &theOffscreen->offscreenWorld->portRect,
- &theOffscreen->windowPort->portRect,
- srcCopy,0L);
-
- UnlockPixels(theOffscreen->offscreenWorld->portPixMap);
- DisposeGWorld(theOffscreen->offscreenWorld);
- DisposePtr((Ptr)theOffscreen);
- }
- }
-